package nl.ceasaro.jeslee.core.model.person;

import nl.ceasaro.jeslee.core.model.AbstractEntity;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: Oct 7, 2008
 * Time: 8:32:09 PM
 * <p>
 * An authenticated person in the system.
 * </p>
 */
public class User extends AbstractEntity
{
   private static final long serialVersionUID = 5054788981446718333L;

   private String name;
   private String email;
   private transient String password;
   private Gender gender;
   private Address address;

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public String getEmail()
   {
      return email;
   }

   public void setEmail(String email)
   {
      this.email = email;
   }

   public String getPassword()
   {
      return password;
   }

   public void setPassword(String password)
   {
      this.password = password;
   }

   public Gender getGender()
   {
      return gender;
   }

   public void setGender(Gender gender)
   {
      this.gender = gender;
   }

   public Address getAddress()
   {
      return address;
   }

   public void setAddress(Address address)
   {
      this.address = address;
   }

   @Override
   public String toString()
   {
      ToStringBuilder toStringBuilder = new ToStringBuilder(this);
      toStringBuilder.append(getName());
      toStringBuilder.append(getEmail());
      toStringBuilder.append(getGender());
      return toStringBuilder.toString();
   }

   @Override
   public boolean equals(Object obj)
   {
      if (this == obj)
      {
         return true;
      }
      if (!(obj instanceof User))
      {
         return false;
      }

      User user = (User) obj;

      if (getEmail() != null ? !getEmail().equals(user.getEmail()) : user.getEmail() != null)
      {
         return false;
      }

      return true;
   }

   @Override
   public int hashCode()
   {
      int result;
      result = getEmail() != null ? getEmail().hashCode() : 0;
      return result;
   }
}
